package com.varian.tool.enums;

import com.varian.tool.exception.ServerException;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
 * @author ben
 * @since 2024/6/22
 */
@Getter
@RequiredArgsConstructor
public enum EnvironmentProfileEnum {

    /**
     * 开发环境
     */
    DEV("dev"),
    /**
     * 测试环境
     */
    TEST("test"),
    /**
     * 生产环境
     */
    PROD("prod");

    private final String profile;

    public static EnvironmentProfileEnum of(String profile) {
        for (EnvironmentProfileEnum profileEnum : values()) {
            if (profileEnum.getProfile().equalsIgnoreCase(profile)) {
                return profileEnum;
            }
        }
        throw ServerException.of("profile not found: {}", profile);
    }
}
